package com.qianfeng.propertygroup.controller;

import com.github.pagehelper.PageInfo;
import com.qianfeng.propertygroup.pojo.Publicboard;
import com.qianfeng.propertygroup.service.intf.PublicboardService;
import com.qianfeng.propertygroup.vo.PublicboardVo;
import com.qianfeng.propertygroup.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * @author LiXuekai on 2020/12/22
 */
@RestController
@RequestMapping("/publicboard")
public class PublicboardController {
    @Autowired
    PublicboardService publicboardService;

    @PostMapping("/add")
    R addPublicboard(@RequestBody Publicboard publicboard){
        publicboardService.addPublicboard(publicboard);
        return R.setOK(null);
    }
    @PostMapping("/update")
    R updatePublicboard(@RequestBody Publicboard publicboard){
        publicboardService.updatePublicboard(publicboard);
        return R.setOK(null);
    }
    @PostMapping("/delete")
    R deletePublicboard(@RequestBody Long id){
        publicboardService.deletePublicboard(id);
        return R.setOK(null);
    }
    @PostMapping("/all")
    R getAllPublicboard(@RequestParam(defaultValue = "1") int pageNum,@RequestParam(defaultValue = "10") int pageSize){
        PageInfo<PublicboardVo> allPublicboard = publicboardService.getAllPublicboard(pageNum, pageSize);
        return R.setOK(allPublicboard);
    }
    @PostMapping("/get")
    R getPublicboardBuDates(@RequestParam(defaultValue = "1") int pageNum,@RequestParam(defaultValue = "10") int pageSize, Date date){
        PageInfo<Publicboard> publicboardBuDates = publicboardService.getPublicboardBuDates(pageNum, pageSize, date);
        return R.setOK(publicboardBuDates);
    }
}
